home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / c_news / 16 / sets / setsourc / inset.c < prev    next >
C/C++ Source or Header  |  1989-03-09  |  664b  |  26 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "sets.h"
  4. /***************************************************************************/
  5.                  boolean in_set(set *aset, int entity)
  6. /***************************************************************************/
  7. /* Determines if entity is a member. */
  8. {
  9. int bit,i;
  10.  
  11.     /* check to see if the set has that many words & members */
  12.     if(entity > aset->set_size)
  13.         return FALSE;
  14.  
  15.     /* get the bit */
  16.     bit = entity % MEMBERS_PER_WORD;
  17.  
  18.     /* get the right word */
  19.     i = entity / MEMBERS_PER_WORD;
  20.  
  21.     /* detect the bit */
  22.     return (aset->word[i] & (1 << bit)) ? TRUE : FALSE;
  23.  
  24. }  /* end in_set */
  25.  
  26.